Passing options to the Java runtime

For certain situations, you may need to pass some options to the JVM. For example, to increase the maximum amount of memory available to the JVM, we typically use:

java -ms64m -mx128m examples.Console

This means the initial memory available to the JVM is 64MB, while the maximum amount of memory available to the JVM is 128MB. This is frequently necessary when running complex server applications.

The typical options available in java.exe are as follows:

C:\java -h
Usage: java [-options] class [args...]
           (to execute a class)
   or  java -jar [-options] jarfile [args...]
           (to execute a jar file)

where options include:
    -client       to select the "client" VM
    -server       to select the "server" VM
    -hotspot      is a synonym for the "client" VM  [deprecated]
                  The default VM is client.

    -cp -classpath <directories and zip/jar files separated by ;>
                  set search path for application classes and resources
    -D<name>=<value>
                  set a system property
    -verbose[:class|gc|jni]
                  enable verbose output
    -version      print product version and exit
    -showversion  print product version and continue
    -? -help      print this help message
    -X            print help on non-standard options
    -ea[:<packagename>...|:<classname>]
    -enableassertions[:<packagename>...|:<classname>]
                  enable assertions
    -da[:<packagename>...|:<classname>]
    -disableassertions[:<packagename>...|:<classname>]
                  disable assertions
    -esa | -enablesystemassertions
                  enable system assertions
    -dsa | -disablesystemassertions
                  disable system assertions

However, because NativeJ's executable operates at a lower level than java.exe, you cannot use the standard options such as -ms, - mx, -cp etc. Instead, you will need to use non-standard options prefixed by -X.

C:\java -X
    -Xmixed           mixed mode execution (default)
    -Xint             interpreted mode execution only
    -Xbootclasspath:  <directories and zip/jar files separated by ;>
                      set search path for bootstrap classes and resources
    -Xbootclasspath/a:<directories and zip/jar files separated by ;>
                      append to end of bootstrap class path
    -Xbootclasspath/p:<directories and zip/jar files separated by ;>
                      prepend in front of bootstrap class path
    -Xnoclassgc       disable class garbage collection
    -Xincgc           enable incremental garbage collection
    -Xloggc:<file>    log GC status to a file with time stamps
    -Xbatch           disable background compilation
    -Xms<size>        set initial Java heap size
    -Xmx<size>        set maximum Java heap size
    -Xss<size>        set java thread stack size
    -Xprof            output cpu profiling data
    -Xrunhprof[:help]|[:<option>=<value>, ...]
                      perform JVMPI heap, cpu, or monitor profiling
    -Xdebug           enable remote debugging
    -Xfuture          enable strictest checks, anticipating future default
    -Xrs              reduce use of OS signals by Java/VM
    -Xcheck:jni       perform additional checks for JNI functions

The -X options are non-standard and subject to change without notice.

Hence, to increase the maximum amount of memory available to an application under NativeJ, you need to specify -Xms64m -Xmx128m under the JVM options parameter box.

Since the -X options are non-standard options and vary across different makes and versions of JVMs, this approach works best if you are bundling a private JRE so that you can be sure that the -X options that you supply will work with the bundled JVM.